package com.mike.employment.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mike.employment.dao.AccountDao;
import com.mike.employment.dao.ApplyDao;
import com.mike.employment.dao.NoticeDao;
import com.mike.employment.dao.OfferDao;
import com.mike.employment.dao.RecruitDao;
import com.mike.employment.service.AnaylizeService;

@Service
public class AnaylizeServiceImpl implements AnaylizeService{

	@Autowired
	private AccountDao accountDao;
	@Autowired
	private OfferDao  offerDao;
	@Autowired
	private RecruitDao recruitDao;
	@Autowired
	private ApplyDao applyDao;
	@Autowired
	private NoticeDao  noticeDao;
	
	@Override
	public Map<String, Long> getAdminData() {
		Map<String,Long> result = new HashMap();
		result.put("student_nums", accountDao.countByRole_code("student"));
		result.put("company_nums", accountDao.countByRole_code("company"));
		Long num1 = accountDao.countByRole_code("admin");
		Long num2 = accountDao.countByRole_code("teacher");
		result.put("admin_nums", num1 + num2);
		result.put("employment_nums", offerDao.countByStatus(1));
		result.put("job_nums", recruitDao.countByStatus(1));
		return result;
	}

	@Override
	public Map<String, Long> getStudentData(Long accountId) {
		Map<String,Long> result = new HashMap();
		result.put("apply_job_nums", applyDao.countByResume_Creater_id(accountId));
		result.put("apply_job_pass_nums", applyDao.countByResume_Creater_idAndStatus(accountId, 1));
		result.put("get_offer_pass_nums", offerDao.countByStatusAndApply_Resume_Creater_id(1, accountId));
		result.put("get_offer_nums", offerDao.countByApply_Resume_Creater_id(accountId));
		return result;
	}

	@Override
	public Map<String, Long> getCompanyData(Long accountId) {
		Map<String,Long> result = new HashMap();
		result.put("get_recruit_nums", applyDao.countByRecruit_Creater_id(accountId));
		result.put("audit_recruit_pass_nums", applyDao.countByRecruit_Creater_idAndStatus(accountId,1));
		result.put("send_offer_pass_nums", offerDao.countByStatusAndApply_Recruit_Creater_id(1, accountId));
		result.put("send_pass_nums", offerDao.countByApply_Recruit_Creater_id(accountId));
		return result;
	}

	@Override
	public Map<String, Long> getTeacherData(Long accountId) {
		Map<String,Long> result = new HashMap();
		result.put("notice_nums", noticeDao.countByCreater_idAndStatus(accountId,1));
		result.put("review_recruit_nums", recruitDao.countByStatus(0));
		result.put("review_pass_nums", recruitDao.countByStatus(1));
		return result;
	}

}
